package com.tie.service;

import com.tie.repository.UserRepository;
import com.tie.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {

    @Autowired
    private UserRepository userRepository;

    public User findByPhone(String phone) {
        User user = null;
        try {
            user = userRepository.findUserByPhone(phone);
        } catch (Exception e) {
            return user;
        }
        return user;
    }

    public void save(User user) {
        userRepository.save(user);
    }

    public User findUserByPassword(String phone,String password) {

        User user = null;
        try {
          user =  userRepository.findUserByPassword(phone,password);
        } catch (Exception e) {
            return user;
        }
        return user;
    }
}
